package org.linloong.modules.apis.monitor.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.linloong.core.result.Result;
import org.linloong.modules.apis.monitor.dto.BarEchartsDataDTO;
import org.linloong.modules.apis.monitor.dto.BarHomeDataDTO;
import org.linloong.modules.apis.monitor.dto.DeviceInfoDTO;
import org.linloong.modules.apis.monitor.dto.LineEchartsDataDTO;
import org.linloong.modules.apis.monitor.service.DataMonitorService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/data/manager/")
@RequiredArgsConstructor
@Tag(name = "数据管理页面接口", description = "所有的图表数据接口")
public class DataMonitorController {

    private final DataMonitorService dataMonitorService;

    @Operation(summary = "获取所有当前生境参数值")
    @GetMapping("/habitat/current")
    public LineEchartsDataDTO getCurrentHabitatData() {
        return null;
    }

    @Operation(summary = "根据类型获取生境参数折线图")
    @GetMapping("/habitat/getLineData/{type}")
    public Result<LineEchartsDataDTO> getHabitatDataByType(@PathVariable String type,
                                                           @RequestParam(defaultValue = "12") @Parameter(description = "获取横轴数量，最小为1个，不填默认12个", example = "12")Integer limit){
        return Result.success(dataMonitorService.getHabitatDataByType(type, limit));
    }

    @Operation(summary = "获取左侧柱状图数据")
    @GetMapping("/average/getBarData")
    public Result<List<BarEchartsDataDTO>> getBarData(){
        return Result.success(dataMonitorService.getBarData());
    }

    @Operation(summary = "获取左侧柱状图外部数据")
    @GetMapping("/average/getBarHomeData")
    public Result<List<BarHomeDataDTO>> getBarHomeData(){
        return Result.success(dataMonitorService.getBarHomeData());
    }

    @Operation(summary = "获取最新的物候图片地址", description = "获取最新的物候图片地址")
    @GetMapping("/getPicUrl")
    public Result<String> getPicUrl(){

        return Result.success(dataMonitorService.getPicUrl());
    }

    @Operation(summary = "获取森林生长设备信息", description = "获取森林生长设备信息")
    @GetMapping("/getDevicesInfo")
    public Result<List<DeviceInfoDTO>> getDevicesInfo(){
        return Result.success(dataMonitorService.getDevicesInfo());
    }

    @Operation(summary = "获取森林生长设备折线图", description = "获取森林生长设备折线图")
    @GetMapping("/getDeviceLineData/{id}")
    public Result<LineEchartsDataDTO> getDeviceLineData(@PathVariable String id,
                                                         @RequestParam(defaultValue = "14") @Parameter(description = "获取横轴数量，最小为1个，不填默认14个", example = "14")Integer limit){
        return Result.success(dataMonitorService.getDeviceLineData(id, limit));
    }
}
